import { createRouter, createWebHistory } from "vue-router";
import pinia from "../store";
import { useRouterStore, useIndexStore } from "../store/path";
const routerStore = useRouterStore(pinia);
const indexStore = useIndexStore(pinia);
// const index = () => import("@/view/homeindex/index.vue");
const lists = () => import("@/view/index/index.vue");
// const windowmembrane = () => import("@/view/windowmembrane/windowmembrane.vue");
const paintprotection = () =>
    import("@/view/paintprotection/index.vue");
const store = () => import("@/view/store/index.vue");
const news = () => import("@/view/news/index.vue");
const notFound = () => import("@/view/notFound/index.vue");

const routes = [
    // {
    //     path: "/",
    //     component: index,
    // },

    {
        path: "/",
        component: lists,
    },
    {
        path: "/windowmembrane",//产品中心的汽车窗膜
        component: () => import("@/view/windowmembrane/index.vue"),
    },
    {
        path: "/concatus",//联系我们
        component: () => import("@/view/concatus/index.vue"),
    },
    {
        path: "/paintprotection",//产品中心的漆面保护膜
        component: paintprotection,
    },
    {
        path: "/construction",//建筑家居保护膜
        component: () => import("@/view/construction/index.vue"),
        meta: {
            title: "建筑家居膜",
        },
    },
    {
        path: "/store",//服务中心
        component: store,
    },
    {
        path: "/news",
        component: news,
    },
    {
        path: "/dyshare",
        component: () => import("@/view/dyshare/index.vue"),
    },
    {
        path: "/news/detail",
        component: () => import("@/view/news/detail.vue"),
    },
    {
        path: "/aboutus",//关于我们
        component: () => import("@/view/aboutus/index.vue"),
    },
    {
        path: "/404",
        name: "404",
        component: notFound,
    },
    {
        path: "/:pathMatch(.*)",
        redirect: "/404",
    },
];

const router = createRouter({
    history: createWebHistory(),
    linkActiveClass: "active",
    routes: routes,
    scrollBehavior() {
        return { top: 0 };
    },
});
router.beforeEach((to, from, next) => {
    routerStore.$patch({
        currentPage: to.name,
    });
    // indexStore.$patch({
    //     showLoading: true
    // })
    next();
});
export default router;
